javascript problem sorting an array of objects